//
//  DesignerTableViewCell.m
//  CarOfHome2
//
//  Created by 微 醺 on 15/9/28.
//  Copyright (c) 2015年 Frank. All rights reserved.
//

#import "DesignerTableViewCell.h"
#import "CollectionModel.h"

@implementation DesignerTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.PersonImg = [[UIImageView alloc] init];
//        self.PersonImg.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_PersonImg];
        
        self.title = [[UILabel alloc] init];
//        self.title.backgroundColor= [UIColor cyanColor];
        [self.contentView addSubview:_title];
        
        self.text = [[UILabel alloc] init];
//        self.text.backgroundColor = [UIColor greenColor];
        [self.contentView addSubview:_text];
        
        self.wenzi1 = [[UILabel alloc] init];
//        self.wenzi1.backgroundColor = [UIColor yellowColor];
        self.wenzi1.text = @"整套改装报价:";
        [self.contentView addSubview:_wenzi1];
        
        self.price = [[UILabel alloc] init];
//        self.price.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:_price];
        
        self.wenzi2 = [[UILabel alloc] init];
//        self.wenzi2.backgroundColor = [UIColor yellowColor];
        self.wenzi2.text = @"元/套";
        [self.contentView addSubview:_wenzi2];
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    AppDelegate *dele = [[UIApplication sharedApplication]delegate];
    if (dele.isNight == 1) {
        self.contentView.backgroundColor = [UIColor blackColor];
        self.text.textColor = [UIColor whiteColor];
        self.title.textColor = [UIColor whiteColor];
  
    }
    else{
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.text.textColor = [UIColor grayColor];
        self.title.textColor = [UIColor blackColor];
      
    }

    self.PersonImg.frame = CGRectMake(SAWindth * 10, SAHeight * 20, SAWindth * 80, SAHeight * 80);
    //设置圆角
    self.PersonImg.layer.cornerRadius = 40;
    self.PersonImg.layer.masksToBounds = YES;
    
    self.title.frame = CGRectMake(SAWindth * 120, SAHeight * 10, SAWindth * 250, SAHeight * 30);
    self.title.font = [UIFont boldSystemFontOfSize:17];
    self.text.frame = CGRectMake(SAWindth * 120, SAHeight * 40, SAWindth * 250, SAHeight * 40);
    self.text.numberOfLines = 0;
    self.text.textColor = [UIColor grayColor];
    self.text.font = [UIFont systemFontOfSize:16];
    self.wenzi1.frame = CGRectMake(SAWindth * 120, SAHeight * 80, SAWindth * 120, SAHeight * 20);
    self.wenzi1.textColor = [UIColor redColor];
    self.price.frame = CGRectMake(SAWindth * 230, SAHeight * 80, SAWindth * 80, SAHeight * 20);
    self.price.textColor = [UIColor redColor];
    self.price.font = [UIFont systemFontOfSize:18];
    self.wenzi2.frame = CGRectMake(SAWindth * 290, SAHeight * 80, SAWindth * 50, SAHeight * 20);
    self.wenzi2.textColor = [UIColor redColor];
    self.wenzi2.font = [UIFont systemFontOfSize:18];
}


- (void)setModel:(CollectionModel *)model
{
    _model = model;
    
    [self.PersonImg sd_setImageWithURL:[NSURL URLWithString:model.person.avatar] placeholderImage:nil];
    if ([[NSString stringWithFormat:@"%@", model.price] isEqualToString:@"0"])
    {
        self.price.text = @"暂无报价";
        self.wenzi2.hidden = YES;
        
    }
    else
    {
        self.price.text = [NSString stringWithFormat:@"%@", model.price];
    }
    self.title.text = model.person.name;
    self.text.text = model.person.title;

    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
